set(CMAKE_CXX_STANDARD 17)

set(TEST_SOURCE_FILE
    test_behavior_tree.cpp
    test_behavior_func.cpp
    test_behavior_class.cpp
    test_behavior_class_sync.cpp
    test_other.cpp
    test_sequence_scheduler.cpp
    test_fallback_scheduler.cpp
    test_parallel_scheduler.cpp
    test_retry_scheduler.cpp
    test_repeat_scheduler.cpp
    test_delay_scheduler.cpp
    test_inverter_scheduler.cpp
    test_force_failure_scheduler.cpp
    test_force_success_scheduler.cpp
    test_reactive_scheduler.cpp
    test_if_else_scheduler.cpp
    test_while_do_scheduler.cpp
    test_union_scheduler.cpp
    test_task_controller.cpp
    test_utils_thread.cpp
    test_task_context.cpp
    test_task_chain.cpp
    test_task_timeout.cpp
    test_log.cpp
    test_reflex.cpp
    test_script_scan.cpp
    test_script_parser.cpp
    test_script_analyzer.cpp
    test_script_run_if.cpp
    test_script_run_while.cpp
    test_script_run_reactive.cpp
    test_script_run_repeat.cpp
    test_script_run_retry.cpp
    test_script_run_force.cpp
    test_script_run_parallel.cpp
    test_script_run_function.cpp
    test_type_utils.cpp
    test_main.cpp
)

aux_source_directory(../utils/utils TEST_UTILS_FILE)
aux_source_directory(../utils/thread TEST_UTILS_THREAD_FILE)
aux_source_directory(../src/scheduler TEST_SCHEDULER_FILE)
aux_source_directory(../src/policy TEST_POLICY_FILE)
aux_source_directory(../src/policy/behavior_tree TEST_POLICY_BEHAVIOR_TREE_FILE)
aux_source_directory(../src/task/behavior_tree_cpp DIR_BEHAVIOR_TREE_FILE)
aux_source_directory(../src/task DIR_TASK_FILE)
aux_source_directory(../src/exclude DIR_EXCLUDE_CPP)
aux_source_directory(../src/scripting DIR_SCRIPTING_FILE)

find_package(GTest REQUIRED)

include_directories(../3rdparty/BehaviorTree.CPP/include)
link_directories(../3rdparty/libs)

add_executable(${PROJECT_NAME}_unit_test
    ${TEST_SOURCE_FILE}
    ${TEST_UTILS_FILE}
    ${TEST_UTILS_THREAD_FILE}
    ${TEST_SCHEDULER_FILE}
    ${TEST_POLICY_FILE}
    ${DIR_BEHAVIOR_TREE_FILE}
    ${TEST_POLICY_BEHAVIOR_TREE_FILE}
    ${DIR_TASK_FILE}
    ${DIR_SCRIPTING_FILE}
    ../src/types/reflex.cpp
    ../src/exclude/same_name_task_chain_exclude_policy.cpp
    ../src/logger/logger.cpp
)
target_link_libraries(${PROJECT_NAME}_unit_test -lgtest pthread ${PROJECT_SOURCE_DIR}/3rdparty/libs/libbehaviortree_cpp_v3.a -ldl)
